package com.zdsoft.crm.service.clue.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zdsoft.crm.dao.clue.ICluePoolMapper;
import com.zdsoft.crm.entity.Clue;
import com.zdsoft.crm.service.clue.ICluePoolService;
import com.zdsoft.crm.vo.PageVo;

@Service
@Transactional
public class CluePoolServiceImpl implements ICluePoolService{

	@Autowired
	ICluePoolMapper cluePoolMapper;
	
	@Override
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(cluePoolMapper.pageList(beginIndex, endIndex));
		pageVo.setTotalCount(cluePoolMapper.totalCount("","").intValue());
		return pageVo;
	}

	@Override
	public int delete(String id) {
		return cluePoolMapper.delete(id);
	}


	@Override
	public int getMyClue(Clue clue) {
		return cluePoolMapper.getMyClue(clue);
	}

	@Override
	public PageVo pageListWhere(Integer pageNum, Integer pageSize, String criteriaType, String content) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(cluePoolMapper.pageListWhere(beginIndex, endIndex,criteriaType,content));
		pageVo.setTotalCount(cluePoolMapper.totalCount(criteriaType,content).intValue());
		return pageVo;
	}

	@Override
	public int distributeClue(String clueId, String userId) {
		return cluePoolMapper.distributeClue(clueId, userId);
	}

	

}
